package com.yunhe.java.Day12;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

/**
 * Created by Administrator on 2017/8/5 0005.
 */
public class SetDemo {
    public static void main(String[] args) {
        Set<Person> set= new TreeSet<>();
//        set.add("1");
//        set.add("5");
//        set.add("10");
//        set.add("2");
        Person p1= new Person("王二16",16);
        Person p2= new Person("王二18",18);
        Person p3= new Person("王二26",26);
        Person p4= new Person("王二36",36);
        set.add(p1);
        set.add(p2);
        set.add(p3);
        set.add(p4);
//        for(Object a:set) {
//            System.out.println(a+ " ");
//        }
        Iterator<Person>iterator= set.iterator();
        while (iterator.hasNext()){
            Person p = iterator.next();
            System.out.println(p.getAge());
        }
    }
}
